home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / dev / c / flex246.lha / gen.c < prev    next >
C/C++ Source or Header  |  1994-01-04  |  33KB  |  1,454 lines

  1. /* gen - actual generation (writing) of flex scanners */
  2.  
  3. /*-
  4.  * Copyright (c) 1990 The Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * This code is derived from software contributed to Berkeley by
  8.  * Vern Paxson.
  9.  * 
  10.  * The United States Government has rights in this work pursuant
  11.  * to contract no. DE-AC03-76SF00098 between the United States
  12.  * Department of Energy and the University of California.
  13.  *
  14.  * Redistribution and use in source and binary forms are permitted provided
  15.  * that: (1) source distributions retain this entire copyright notice and
  16.  * comment, and (2) distributions including binaries display the following
  17.  * acknowledgement:  ``This product includes software developed by the
  18.  * University of California, Berkeley and its contributors'' in the
  19.  * documentation or other materials provided with the distribution and in
  20.  * all advertising materials mentioning features or use of this software.
  21.  * Neither the name of the University nor the names of its contributors may
  22.  * be used to endorse or promote products derived from this software without
  23.  * specific prior written permission.
  24.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  25.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  26.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27.  */
  28.  
  29. /* $Header: gen.c,v 1.2 94/01/04 14:33:12 vern Exp $ */
  30.  
  31. #include "flexdef.h"
  32.  
  33.  
  34. /* declare functions that have forward references */
  35.  
  36. void gen_next_state PROTO((int));
  37. void genecs PROTO((void));
  38. void indent_put2s PROTO((char [], char []));
  39. void indent_puts PROTO((char []));
  40.  
  41.  
  42. static int indent_level = 0; /* each level is 8 spaces */
  43.  
  44. #define indent_up() (++indent_level)
  45. #define indent_down() (--indent_level)
  46. #define set_indent(indent_val) indent_level = indent_val
  47.  
  48. /* Almost everything is done in terms of arrays starting at 1, so provide
  49.  * a null entry for the zero element of all C arrays.  (The exception
  50.  * to this is that the fast table representation generally uses the
  51.  * 0 elements of its arrays, too.)
  52.  */
  53. static char C_int_decl[] = "static const int %s[%d] =\n    {   0,\n";
  54. static char C_short_decl[] = "static const short int %s[%d] =\n    {   0,\n";
  55. static char C_long_decl[] = "static const long int %s[%d] =\n    {   0,\n";
  56. static char C_state_decl[] =
  57.     "static const yy_state_type %s[%d] =\n    {   0,\n";
  58.  
  59.  
  60. /* Indent to the current level. */
  61.  
  62. void do_indent()
  63.     {
  64.     register int i = indent_level * 8;
  65.  
  66.     while ( i >= 8 )
  67.         {
  68.         putchar( '\t' );
  69.         i -= 8;
  70.         }
  71.  
  72.     while ( i > 0 )
  73.         {
  74.         putchar( ' ' );
  75.         --i;
  76.         }
  77.     }
  78.  
  79.  
  80. /* Generate the code to keep backing-up information. */
  81.  
  82. void gen_backing_up()
  83.     {
  84.     if ( reject || num_backing_up == 0 )
  85.         return;
  86.  
  87.     if ( fullspd )
  88.         indent_puts( "if ( yy_current_state[-1].yy_nxt )" );
  89.     else
  90.         indent_puts( "if ( yy_accept[yy_current_state] )" );
  91.  
  92.     indent_up();
  93.     indent_puts( "{" );
  94.     indent_puts( "yy_last_accepting_state = yy_current_state;" );
  95.     indent_puts( "yy_last_accepting_cpos = yy_cp;" );
  96.     indent_puts( "}" );
  97.     indent_down();
  98.     }
  99.  
  100.  
  101. /* Generate the code to perform the backing up. */
  102.  
  103. void gen_bu_action()
  104.     {
  105.     if ( reject || num_backing_up == 0 )
  106.         return;
  107.  
  108.     set_indent( 3 );
  109.  
  110.     indent_puts( "case 0: /* must back up */" );
  111.     indent_puts( "/* undo the effects of YY_DO_BEFORE_ACTION */" );
  112.     indent_puts( "*yy_cp = yy_hold_char;" );
  113.  
  114.     if ( fullspd || fulltbl )
  115.         indent_puts( "yy_cp = yy_last_accepting_cpos + 1;" );
  116.     else
  117.         /* Backing-up info for compressed tables is taken \after/
  118.          * yy_cp has been incremented for the next state.
  119.          */
  120.         indent_puts( "yy_cp = yy_last_accepting_cpos;" );
  121.  
  122.     indent_puts( "yy_current_state = yy_last_accepting_state;" );
  123.     indent_puts( "goto yy_find_action;" );
  124.     putchar( '\n' );
  125.  
  126.     set_indent( 0 );
  127.     }
  128.  
  129.  
  130. /* genctbl - generates full speed compressed transition table */
  131.  
  132. void genctbl()
  133.     {
  134.     register int i;
  135.     int end_of_buffer_action = num_rules + 1;
  136.  
  137.     /* Table of verify for transition and offset to next state. */
  138.     printf( "static const struct yy_trans_info yy_transition[%d] =\n",
  139.         tblend + numecs + 1 );
  140.     printf( "    {\n" );
  141.  
  142.     /* We want the transition to be represented as the offset to the
  143.      * next state, not the actual state number, which is what it currently
  144.      * is.  The offset is base[nxt[i]] - (base of current state)].  That's
  145.      * just the difference between the starting points of the two involved
  146.      * states (to - from).
  147.      *
  148.      * First, though, we need to find some way to put in our end-of-buffer
  149.      * flags and states.  We do this by making a state with absolutely no
  150.      * transitions.  We put it at the end of the table.
  151.      */
  152.  
  153.     /* We need to have room in nxt/chk for two more slots: One for the
  154.      * action and one for the end-of-buffer transition.  We now *assume*
  155.      * that we're guaranteed the only character we'll try to index this
  156.      * nxt/chk pair with is EOB, i.e., 0, so we don't have to make sure
  157.      * there's room for jam entries for other characters.
  158.      */
  159.  
  160.     while ( tblend + 2 >= current_max_xpairs )
  161.         expand_nxt_chk();
  162.  
  163.     while ( lastdfa + 1 >= current_max_dfas )
  164.         increase_max_dfas();
  165.  
  166.     base[lastdfa + 1] = tblend + 2;
  167.     nxt[tblend + 1] = end_of_buffer_action;
  168.     chk[tblend + 1] = numecs + 1;
  169.     chk[tblend + 2] = 1; /* anything but EOB */
  170.  
  171.     /* So that "make test" won't show arb. differences. */
  172.     nxt[tblend + 2] = 0;
  173.  
  174.     /* Make sure every state has an end-of-buffer transition and an
  175.      * action #.
  176.      */
  177.     for ( i = 0; i <= lastdfa; ++i )
  178.         {
  179.         int anum = dfaacc[i].dfaacc_state;
  180.         int offset = base[i];
  181.  
  182.         chk[offset] = EOB_POSITION;
  183.         chk[offset - 1] = ACTION_POSITION;
  184.         nxt[offset - 1] = anum;    /* action number */
  185.         }
  186.  
  187.     for ( i = 0; i <= tblend; ++i )
  188.         {
  189.         if ( chk[i] == EOB_POSITION )
  190.             transition_struct_out( 0, base[lastdfa + 1] - i );
  191.  
  192.         else if ( chk[i] == ACTION_POSITION )
  193.             transition_struct_out( 0, nxt[i] );
  194.  
  195.         else if ( chk[i] > numecs || chk[i] == 0 )
  196.             transition_struct_out( 0, 0 );    /* unused slot */
  197.  
  198.         else    /* verify, transition */
  199.             transition_struct_out( chk[i],
  200.                         base[nxt[i]] - (i - chk[i]) );
  201.         }
  202.  
  203.  
  204.     /* Here's the final, end-of-buffer state. */
  205.     transition_struct_out( chk[tblend + 1], nxt[tblend + 1] );
  206.     transition_struct_out( chk[tblend + 2], nxt[tblend + 2] );
  207.  
  208.     printf( "    };\n" );
  209.     printf( "\n" );
  210.  
  211.     /* Table of pointers to start states. */
  212.     printf(
  213.     "static const struct yy_trans_info *yy_start_state_list[%d] =\n",
  214.         lastsc * 2 + 1 );
  215.     printf( "    {\n" );    /* } so vi doesn't get confused */
  216.  
  217.     for ( i = 0; i <= lastsc * 2; ++i )
  218.         printf( "    &yy_transition[%d],\n", base[i] );
  219.  
  220.     dataend();
  221.  
  222.     if ( useecs )
  223.         genecs();
  224.     }
  225.  
  226.  
  227. /* Generate equivalence-class tables. */
  228.  
  229. void genecs()
  230.     {
  231.     Char clower();
  232.     register int i, j;
  233.     int numrows;
  234.  
  235.     printf( C_int_decl, "yy_ec", csize );
  236.  
  237.     for ( i = 1; i < csize; ++i )
  238.         {
  239.         if ( caseins && (i >= 'A') && (i <= 'Z') )
  240.             ecgroup[i] = ecgroup[clower( i )];
  241.  
  242.         ecgroup[i] = ABS( ecgroup[i] );
  243.         mkdata( ecgroup[i] );
  244.         }
  245.  
  246.     dataend();
  247.  
  248.     if ( trace )
  249.         {
  250.         fputs( "\n\nEquivalence Classes:\n\n", stderr );
  251.  
  252.         numrows = csize / 8;
  253.  
  254.         for ( j = 0; j < numrows; ++j )
  255.             {
  256.             for ( i = j; i < csize; i = i + numrows )
  257.                 {
  258.                 fprintf( stderr, "%4s = %-2d",
  259.                     readable_form( i ), ecgroup[i] );
  260.  
  261.                 putc( ' ', stderr );
  262.                 }
  263.  
  264.             putc( '\n', stderr );
  265.             }
  266.         }
  267.     }
  268.  
  269.  
  270. /* Generate the code to find the action number. */
  271.  
  272. void gen_find_action()
  273.     {
  274.     if ( fullspd )
  275.         indent_puts( "yy_act = yy_current_state[-1].yy_nxt;" );
  276.  
  277.     else if ( fulltbl )
  278.         indent_puts( "yy_act = yy_accept[yy_current_state];" );
  279.  
  280.     else if ( reject )
  281.         {
  282.         indent_puts( "yy_current_state = *--yy_state_ptr;" );
  283.         indent_puts( "yy_lp = yy_accept[yy_current_state];" );
  284.  
  285.         puts(
  286.         "find_rule: /* we branch to this label when backing up */" );
  287.  
  288.         indent_puts(
  289.         "for ( ; ; ) /* until we find what rule we matched */" );
  290.  
  291.         indent_up();
  292.  
  293.         indent_puts( "{" );
  294.  
  295.         indent_puts(
  296.         "if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )" );
  297.         indent_up();
  298.         indent_puts( "{" );
  299.         indent_puts( "yy_act = yy_acclist[yy_lp];" );
  300.  
  301.         if ( variable_trailing_context_rules )
  302.             {
  303.             indent_puts( "if ( yy_act & YY_TRAILING_HEAD_MASK ||" );
  304.             indent_puts( "     yy_looking_for_trail_begin )" );
  305.             indent_up();
  306.             indent_puts( "{" );
  307.  
  308.             indent_puts(
  309.                 "if ( yy_act == yy_looking_for_trail_begin )" );
  310.             indent_up();
  311.             indent_puts( "{" );
  312.             indent_puts( "yy_looking_for_trail_begin = 0;" );
  313.             indent_puts( "yy_act &= ~YY_TRAILING_HEAD_MASK;" );
  314.             indent_puts( "break;" );
  315.             indent_puts( "}" );
  316.             indent_down();
  317.  
  318.             indent_puts( "}" );
  319.             indent_down();
  320.  
  321.             indent_puts( "else if ( yy_act & YY_TRAILING_MASK )" );
  322.             indent_up();
  323.             indent_puts( "{" );
  324.             indent_puts(
  325.         "yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK;" );
  326.             indent_puts(
  327.         "yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK;" );
  328.  
  329.             if ( real_reject )
  330.                 {
  331.                 /* Remember matched text in case we back up
  332.                  * due to REJECT.
  333.                  */
  334.                 indent_puts( "yy_full_match = yy_cp;" );
  335.                 indent_puts( "yy_full_state = yy_state_ptr;" );
  336.                 indent_puts( "yy_full_lp = yy_lp;" );
  337.                 }
  338.  
  339.             indent_puts( "}" );
  340.             indent_down();
  341.  
  342.             indent_puts( "else" );
  343.             indent_up();
  344.             indent_puts( "{" );
  345.             indent_puts( "yy_full_match = yy_cp;" );
  346.             indent_puts( "yy_full_state = yy_state_ptr;" );
  347.             indent_puts( "yy_full_lp = yy_lp;" );
  348.             indent_puts( "break;" );
  349.             indent_puts( "}" );
  350.             indent_down();
  351.  
  352.             indent_puts( "++yy_lp;" );
  353.             indent_puts( "goto find_rule;" );
  354.             }
  355.  
  356.         else
  357.         {
  358.         /* Remember matched text in case we back up due to trailing
  359.          * context plus REJECT.
  360.          */
  361.         indent_up();
  362.         indent_puts( "{" );
  363.         indent_puts( "yy_full_match = yy_cp;" );
  364.         indent_puts( "break;" );
  365.         indent_puts( "}" );
  366.         indent_down();
  367.         }
  368.  
  369.         indent_puts( "}" );
  370.         indent_down();
  371.  
  372.         indent_puts( "--yy_cp;" );
  373.  
  374.         /* We could consolidate the following two lines with those at
  375.          * the beginning, but at the cost of complaints that we're
  376.          * branching inside a loop.
  377.          */
  378.         indent_puts( "yy_current_state = *--yy_state_ptr;" );
  379.         indent_puts( "yy_lp = yy_accept[yy_current_state];" );
  380.  
  381.         indent_puts( "}" );
  382.  
  383.         indent_down();
  384.         }
  385.  
  386.     else
  387.         /* compressed */
  388.         indent_puts( "yy_act = yy_accept[yy_current_state];" );
  389.     }
  390.  
  391.  
  392. /* genftbl - generates full transition table */
  393.  
  394. void genftbl()
  395.     {
  396.     register int i;
  397.     int end_of_buffer_action = num_rules + 1;
  398.  
  399.     printf( long_align ? C_long_decl : C_short_decl,
  400.         "yy_accept", lastdfa + 1 );
  401.  
  402.     dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
  403.  
  404.     for ( i = 1; i <= lastdfa; ++i )
  405.         {
  406.         register int anum = dfaacc[i].dfaacc_state;
  407.  
  408.         mkdata( anum );
  409.  
  410.         if ( trace && anum )
  411.             fprintf( stderr, "state # %d accepts: [%d]\n",
  412.                 i, anum );
  413.         }
  414.  
  415.     dataend();
  416.  
  417.     if ( useecs )
  418.         genecs();
  419.  
  420.     /* Don't have to dump the actual full table entries - they were
  421.      * created on-the-fly.
  422.      */
  423.     }
  424.  
  425.  
  426. /* Generate the code to find the next compressed-table state. */
  427.  
  428. void gen_next_compressed_state( char_map )
  429. char *char_map;
  430.     {
  431.     indent_put2s( "register YY_CHAR yy_c = %s;", char_map );
  432.  
  433.     /* Save the backing-up info \before/ computing the next state
  434.      * because we always compute one more state than needed - we
  435.      * always proceed until we reach a jam state
  436.      */
  437.     gen_backing_up();
  438.  
  439.     indent_puts(
  440. "while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )" );
  441.     indent_up();
  442.     indent_puts( "{" );
  443.     indent_puts( "yy_current_state = (int) yy_def[yy_current_state];" );
  444.  
  445.     if ( usemecs )
  446.         {
  447.         /* We've arrange it so that templates are never chained
  448.          * to one another.  This means we can afford to make a
  449.          * very simple test to see if we need to convert to
  450.          * yy_c's meta-equivalence class without worrying
  451.          * about erroneously looking up the meta-equivalence
  452.          * class twice
  453.          */
  454.         do_indent();
  455.  
  456.         /* lastdfa + 2 is the beginning of the templates */
  457.         printf( "if ( yy_current_state >= %d )\n", lastdfa + 2 );
  458.  
  459.         indent_up();
  460.         indent_puts( "yy_c = yy_meta[(unsigned int) yy_c];" );
  461.         indent_down();
  462.         }
  463.  
  464.     indent_puts( "}" );
  465.     indent_down();
  466.  
  467.     indent_puts(
  468. "yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];" );
  469.     }
  470.  
  471.  
  472. /* Generate the code to find the next match. */
  473.  
  474. void gen_next_match()
  475.     {
  476.     /* NOTE - changes in here should be reflected in gen_next_state() and
  477.      * gen_NUL_trans().
  478.      */
  479.     char *char_map = useecs ?
  480.                 "yy_ec[YY_SC_TO_UI(*yy_cp)]" :
  481.                 "YY_SC_TO_UI(*yy_cp)";
  482.  
  483.     char *char_map_2 = useecs ?
  484.                 "yy_ec[YY_SC_TO_UI(*++yy_cp)]" :
  485.                 "YY_SC_TO_UI(*++yy_cp)";
  486.  
  487.     if ( fulltbl )
  488.         {
  489.         indent_put2s(
  490.     "while ( (yy_current_state = yy_nxt[yy_current_state][%s]) > 0 )",
  491.                 char_map );
  492.  
  493.         indent_up();
  494.  
  495.         if ( num_backing_up > 0 )
  496.             {
  497.             indent_puts( "{" );    /* } for vi */
  498.             gen_backing_up();
  499.             putchar( '\n' );
  500.             }
  501.  
  502.         indent_puts( "++yy_cp;" );
  503.  
  504.         if ( num_backing_up > 0 )
  505.             /* { for vi */
  506.             indent_puts( "}" );
  507.  
  508.         indent_down();
  509.  
  510.         putchar( '\n' );
  511.         indent_puts( "yy_current_state = -yy_current_state;" );
  512.         }
  513.  
  514.     else if ( fullspd )
  515.         {
  516.         indent_puts( "{" );    /* } for vi */
  517.         indent_puts(
  518.         "register const struct yy_trans_info *yy_trans_info;\n" );
  519.         indent_puts( "register YY_CHAR yy_c;\n" );
  520.         indent_put2s( "for ( yy_c = %s;", char_map );
  521.         indent_puts(
  522.     "      (yy_trans_info = &yy_current_state[(unsigned int) yy_c])->" );
  523.         indent_puts( "yy_verify == yy_c;" );
  524.         indent_put2s( "      yy_c = %s )", char_map_2 );
  525.  
  526.         indent_up();
  527.  
  528.         if ( num_backing_up > 0 )
  529.             indent_puts( "{" );    /* } for vi */
  530.  
  531.         indent_puts( "yy_current_state += yy_trans_info->yy_nxt;" );
  532.  
  533.         if ( num_backing_up > 0 )
  534.             {
  535.             putchar( '\n' );
  536.             gen_backing_up();    /* { for vi */
  537.             indent_puts( "}" );
  538.             }
  539.  
  540.         indent_down();    /* { for vi */
  541.         indent_puts( "}" );
  542.         }
  543.  
  544.     else
  545.         { /* compressed */
  546.         indent_puts( "do" );
  547.  
  548.         indent_up();
  549.         indent_puts( "{" );    /* } for vi */
  550.  
  551.         gen_next_state( false );
  552.  
  553.         indent_puts( "++yy_cp;" );
  554.  
  555.         /* { for vi */
  556.         indent_puts( "}" );
  557.         indent_down();
  558.  
  559.         do_indent();
  560.  
  561.         if ( interactive )
  562.             printf( "while ( yy_base[yy_current_state] != %d );\n",
  563.                 jambase );
  564.         else
  565.             printf( "while ( yy_current_state != %d );\n",
  566.                 jamstate );
  567.  
  568.         if ( ! reject && ! interactive )
  569.             {
  570.             /* Do the guaranteed-needed backing up to figure out
  571.              * the match.
  572.              */
  573.             indent_puts( "yy_cp = yy_last_accepting_cpos;" );
  574.             indent_puts(
  575.                 "yy_current_state = yy_last_accepting_state;" );
  576.             }
  577.         }
  578.     }
  579.  
  580.  
  581. /* Generate the code to find the next state. */
  582.  
  583. void gen_next_state( worry_about_NULs )
  584. int worry_about_NULs;
  585.     { /* NOTE - changes in here should be reflected in get_next_match() */
  586.     char char_map[256];
  587.  
  588.     if ( worry_about_NULs && ! nultrans )
  589.         {
  590.         if ( useecs )
  591.             (void) sprintf( char_map,
  592.                 "(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : %d)",
  593.                     NUL_ec );
  594.         else
  595.             (void) sprintf( char_map,
  596.                 "(*yy_cp ? YY_SC_TO_UI(*yy_cp) : %d)", NUL_ec );
  597.         }
  598.  
  599.     else
  600.         strcpy( char_map, useecs ? "yy_ec[YY_SC_TO_UI(*yy_cp)]" :
  601.                        "YY_SC_TO_UI(*yy_cp)" );
  602.  
  603.     if ( worry_about_NULs && nultrans )
  604.         {
  605.         if ( ! fulltbl && ! fullspd )
  606.             /* Compressed tables back up *before* they match. */
  607.             gen_backing_up();
  608.  
  609.         indent_puts( "if ( *yy_cp )" );
  610.         indent_up();
  611.         indent_puts( "{" );    /* } for vi */
  612.         }
  613.  
  614.     if ( fulltbl )
  615.         indent_put2s(
  616.             "yy_current_state = yy_nxt[yy_current_state][%s];", 
  617.                 char_map );
  618.  
  619.     else if ( fullspd )
  620.         indent_put2s(
  621.             "yy_current_state += yy_current_state[%s].yy_nxt;",
  622.                 char_map );
  623.  
  624.     else
  625.         gen_next_compressed_state( char_map );
  626.  
  627.     if ( worry_about_NULs && nultrans )
  628.         {
  629.         /* { for vi */
  630.         indent_puts( "}" );
  631.         indent_down();
  632.         indent_puts( "else" );
  633.         indent_up();
  634.         indent_puts(
  635.             "yy_current_state = yy_NUL_trans[yy_current_state];" );
  636.         indent_down();
  637.         }
  638.  
  639.     if ( fullspd || fulltbl )
  640.         gen_backing_up();
  641.  
  642.     if ( reject )
  643.         indent_puts( "*yy_state_ptr++ = yy_current_state;" );
  644.     }
  645.  
  646.  
  647. /* Generate the code to make a NUL transition. */
  648.  
  649. void gen_NUL_trans()
  650.     { /* NOTE - changes in here should be reflected in get_next_match() */
  651.     int need_backing_up = (num_backing_up > 0 && ! reject);
  652.  
  653.     if ( need_backing_up )
  654.         /* We'll need yy_cp lying around for the gen_backing_up(). */
  655.         indent_puts( "register char *yy_cp = yy_c_buf_p;" );
  656.  
  657.     putchar( '\n' );
  658.  
  659.     if ( nultrans )
  660.         {
  661.         indent_puts(
  662.             "yy_current_state = yy_NUL_trans[yy_current_state];" );
  663.         indent_puts( "yy_is_jam = (yy_current_state == 0);" );
  664.         }
  665.  
  666.     else if ( fulltbl )
  667.         {
  668.         do_indent();
  669.         printf( "yy_current_state = yy_nxt[yy_current_state][%d];\n",
  670.             NUL_ec );
  671.         indent_puts( "yy_is_jam = (yy_current_state <= 0);" );
  672.         }
  673.  
  674.     else if ( fullspd )
  675.         {
  676.         do_indent();
  677.         printf( "register int yy_c = %d;\n", NUL_ec );
  678.  
  679.         indent_puts(
  680.         "register const struct yy_trans_info *yy_trans_info;\n" );
  681.         indent_puts(
  682.         "yy_trans_info = &yy_current_state[(unsigned int) yy_c];" );
  683.         indent_puts( "yy_current_state += yy_trans_info->yy_nxt;" );
  684.  
  685.         indent_puts(
  686.             "yy_is_jam = (yy_trans_info->yy_verify != yy_c);" );
  687.         }
  688.  
  689.     else
  690.         {
  691.         char NUL_ec_str[20];
  692.  
  693.         (void) sprintf( NUL_ec_str, "%d", NUL_ec );
  694.         gen_next_compressed_state( NUL_ec_str );
  695.  
  696.         if ( reject )
  697.             indent_puts( "*yy_state_ptr++ = yy_current_state;" );
  698.  
  699.         do_indent();
  700.  
  701.         printf( "yy_is_jam = (yy_current_state == %d);\n", jamstate );
  702.         }
  703.  
  704.     /* If we've entered an accepting state, back up; note that
  705.      * compressed tables have *already* done such backing up, so
  706.      * we needn't bother with it again.
  707.      */
  708.     if ( need_backing_up && (fullspd || fulltbl) )
  709.         {
  710.         putchar( '\n' );
  711.         indent_puts( "if ( ! yy_is_jam )" );
  712.         indent_up();
  713.         indent_puts( "{" );
  714.         gen_backing_up();
  715.         indent_puts( "}" );
  716.         indent_down();
  717.         }
  718.     }
  719.  
  720.  
  721. /* Generate the code to find the start state. */
  722.  
  723. void gen_start_state()
  724.     {
  725.     if ( fullspd )
  726.         indent_put2s(
  727.             "yy_current_state = yy_start_state_list[yy_start%s];",
  728.             bol_needed ? " + (yy_bp[-1] == '\\n' ? 1 : 0)" : "" );
  729.  
  730.     else
  731.         {
  732.         indent_puts( "yy_current_state = yy_start;" );
  733.  
  734.         if ( bol_needed )
  735.             {
  736.             indent_puts( "if ( yy_bp[-1] == '\\n' )" );
  737.             indent_up();
  738.             indent_puts( "++yy_current_state;" );
  739.             indent_down();
  740.             }
  741.  
  742.         if ( reject )
  743.             {
  744.             /* Set up for storing up states. */
  745.             indent_puts( "yy_state_ptr = yy_state_buf;" );
  746.             indent_puts( "*yy_state_ptr++ = yy_current_state;" );
  747.             }
  748.         }
  749.     }
  750.  
  751.  
  752. /* gentabs - generate data statements for the transition tables */
  753.  
  754. void gentabs()
  755.     {
  756.     int i, j, k, *accset, nacc, *acc_array, total_states;
  757.     int end_of_buffer_action = num_rules + 1;
  758.  
  759.     /* *Everything* is done in terms of arrays starting at 1, so provide
  760.      * a null entry for the zero element of all C arrays.
  761.      */
  762.     static char C_char_decl[] =
  763.         "static const YY_CHAR %s[%d] =\n    {   0,\n";    /* } for vi */
  764.  
  765.     acc_array = allocate_integer_array( current_max_dfas );
  766.     nummt = 0;
  767.  
  768.     /* The compressed table format jams by entering the "jam state",
  769.      * losing information about the previous state in the process.
  770.      * In order to recover the previous state, we effectively need
  771.      * to keep backing-up information.
  772.      */
  773.     ++num_backing_up;
  774.  
  775.     if ( reject )
  776.         {
  777.         /* Write out accepting list and pointer list.
  778.          *
  779.          * First we generate the "yy_acclist" array.  In the process,
  780.          * we compute the indices that will go into the "yy_accept"
  781.          * array, and save the indices in the dfaacc array.
  782.          */
  783.         int EOB_accepting_list[2];
  784.  
  785.         /* Set up accepting structures for the End Of Buffer state. */
  786.         EOB_accepting_list[0] = 0;
  787.         EOB_accepting_list[1] = end_of_buffer_action;
  788.         accsiz[end_of_buffer_state] = 1;
  789.         dfaacc[end_of_buffer_state].dfaacc_set = EOB_accepting_list;
  790.  
  791.         printf( long_align ? C_long_decl : C_short_decl,
  792.             "yy_acclist", MAX( numas, 1 ) + 1 );
  793.  
  794.         j = 1;    /* index into "yy_acclist" array */
  795.  
  796.         for ( i = 1; i <= lastdfa; ++i )
  797.             {
  798.             acc_array[i] = j;
  799.  
  800.             if ( accsiz[i] != 0 )
  801.                 {
  802.                 accset = dfaacc[i].dfaacc_set;
  803.                 nacc = accsiz[i];
  804.  
  805.                 if ( trace )
  806.                     fprintf( stderr,
  807.                         "state # %d accepts: ", i );
  808.  
  809.                 for ( k = 1; k <= nacc; ++k )
  810.                     {
  811.                     int accnum = accset[k];
  812.  
  813.                     ++j;
  814.  
  815.                     if ( variable_trailing_context_rules &&
  816.                       ! (accnum & YY_TRAILING_HEAD_MASK) &&
  817.                        accnum > 0 && accnum <= num_rules &&
  818.                       rule_type[accnum] == RULE_VARIABLE )
  819.                         {
  820.                         /* Special hack to flag
  821.                          * accepting number as part
  822.                          * of trailing context rule.
  823.                          */
  824.                         accnum |= YY_TRAILING_MASK;
  825.                         }
  826.  
  827.                     mkdata( accnum );
  828.  
  829.                     if ( trace )
  830.                         {
  831.                         fprintf( stderr, "[%d]",
  832.                             accset[k] );
  833.  
  834.                         if ( k < nacc )
  835.                             fputs( ", ", stderr );
  836.                         else
  837.                             putc( '\n', stderr );
  838.                         }
  839.                     }
  840.                 }
  841.             }
  842.  
  843.         /* add accepting number for the "jam" state */
  844.         acc_array[i] = j;
  845.  
  846.         dataend();
  847.         }
  848.  
  849.     else
  850.         {
  851.         dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
  852.  
  853.         for ( i = 1; i <= lastdfa; ++i )
  854.             acc_array[i] = dfaacc[i].dfaacc_state;
  855.  
  856.         /* add accepting number for jam state */
  857.         acc_array[i] = 0;
  858.         }
  859.  
  860.     /* Spit out "yy_accept" array.  If we're doing "reject", it'll be
  861.      * pointers into the "yy_acclist" array.  Otherwise it's actual
  862.      * accepting numbers.  In either case, we just dump the numbers.
  863.      */
  864.  
  865.     /* "lastdfa + 2" is the size of "yy_accept"; includes room for C arrays
  866.      * beginning at 0 and for "jam" state.
  867.      */
  868.     k = lastdfa + 2;
  869.  
  870.     if ( reject )
  871.         /* We put a "cap" on the table associating lists of accepting
  872.          * numbers with state numbers.  This is needed because we tell
  873.          * where the end of an accepting list is by looking at where
  874.          * the list for the next state starts.
  875.          */
  876.         ++k;
  877.  
  878.     printf( long_align ? C_long_decl : C_short_decl, "yy_accept", k );
  879.  
  880.     for ( i = 1; i <= lastdfa; ++i )
  881.         {
  882.         mkdata( acc_array[i] );
  883.  
  884.         if ( ! reject && trace && acc_array[i] )
  885.             fprintf( stderr, "state # %d accepts: [%d]\n",
  886.                 i, acc_array[i] );
  887.         }
  888.  
  889.     /* Add entry for "jam" state. */
  890.     mkdata( acc_array[i] );
  891.  
  892.     if ( reject )
  893.         /* Add "cap" for the list. */
  894.         mkdata( acc_array[i] );
  895.  
  896.     dataend();
  897.  
  898.     if ( useecs )
  899.         genecs();
  900.  
  901.     if ( usemecs )
  902.         {
  903.         /* Write out meta-equivalence classes (used to index
  904.          * templates with).
  905.          */
  906.  
  907.         if ( trace )
  908.             fputs( "\n\nMeta-Equivalence Classes:\n", stderr );
  909.  
  910.         printf( C_int_decl, "yy_meta", numecs + 1 );
  911.  
  912.         for ( i = 1; i <= numecs; ++i )
  913.             {
  914.             if ( trace )
  915.                 fprintf( stderr, "%d = %d\n",
  916.                     i, ABS( tecbck[i] ) );
  917.  
  918.             mkdata( ABS( tecbck[i] ) );
  919.             }
  920.  
  921.         dataend();
  922.         }
  923.  
  924.     total_states = lastdfa + numtemps;
  925.  
  926.     printf( (tblend >= MAX_SHORT || long_align) ?
  927.             C_long_decl : C_short_decl,
  928.         "yy_base", total_states + 1 );
  929.  
  930.     for ( i = 1; i <= lastdfa; ++i )
  931.         {
  932.         register int d = def[i];
  933.  
  934.         if ( base[i] == JAMSTATE )
  935.             base[i] = jambase;
  936.  
  937.         if ( d == JAMSTATE )
  938.             def[i] = jamstate;
  939.  
  940.         else if ( d < 0 )
  941.             {
  942.             /* Template reference. */
  943.             ++tmpuses;
  944.             def[i] = lastdfa - d + 1;
  945.             }
  946.  
  947.         mkdata( base[i] );
  948.         }
  949.  
  950.     /* Generate jam state's base index. */
  951.     mkdata( base[i] );
  952.  
  953.     for ( ++i /* skip jam state */; i <= total_states; ++i )
  954.         {
  955.         mkdata( base[i] );
  956.         def[i] = jamstate;
  957.         }
  958.  
  959.     dataend();
  960.  
  961.     printf( (total_states >= MAX_SHORT || long_align) ?
  962.             C_long_decl : C_short_decl,
  963.         "yy_def", total_states + 1 );
  964.  
  965.     for ( i = 1; i <= total_states; ++i )
  966.         mkdata( def[i] );
  967.  
  968.     dataend();
  969.  
  970.     printf( (total_states >= MAX_SHORT || long_align) ?
  971.             C_long_decl : C_short_decl,
  972.         "yy_nxt", tblend + 1 );
  973.  
  974.     for ( i = 1; i <= tblend; ++i )
  975.         {
  976.         if ( nxt[i] == 0 || chk[i] == 0 )
  977.             nxt[i] = jamstate;    /* new state is the JAM state */
  978.  
  979.         mkdata( nxt[i] );
  980.         }
  981.  
  982.     dataend();
  983.  
  984.     printf( (total_states >= MAX_SHORT || long_align) ?
  985.             C_long_decl : C_short_decl,
  986.         "yy_chk", tblend + 1 );
  987.  
  988.     for ( i = 1; i <= tblend; ++i )
  989.         {
  990.         if ( chk[i] == 0 )
  991.             ++nummt;
  992.  
  993.         mkdata( chk[i] );
  994.         }
  995.  
  996.     dataend();
  997.     }
  998.  
  999.  
  1000. /* Write out a formatted string (with a secondary string argument) at the
  1001.  * current indentation level, adding a final newline.
  1002.  */
  1003.  
  1004. void indent_put2s( fmt, arg )
  1005. char fmt[], arg[];
  1006.     {
  1007.     do_indent();
  1008.     printf( fmt, arg );
  1009.     putchar( '\n' );
  1010.     }
  1011.  
  1012.  
  1013. /* Write out a string at the current indentation level, adding a final
  1014.  * newline.
  1015.  */
  1016.  
  1017. void indent_puts( str )
  1018. char str[];
  1019.     {
  1020.     do_indent();
  1021.     puts( str );
  1022.     }
  1023.  
  1024.  
  1025. /* make_tables - generate transition tables and finishes generating output file
  1026.  */
  1027.  
  1028. void make_tables()
  1029.     {
  1030.     register int i;
  1031.     int did_eof_rule = false;
  1032.  
  1033.     skelout();
  1034.  
  1035.     /* First, take care of YY_DO_BEFORE_ACTION depending on yymore
  1036.      * being used.
  1037.      */
  1038.     set_indent( 1 );
  1039.  
  1040.     if ( yymore_used )
  1041.         {
  1042.         indent_puts( "yytext_ptr -= yy_more_len; \\" );
  1043.         indent_puts( "yyleng = yy_cp - yytext_ptr; \\" );
  1044.         }
  1045.  
  1046.     else
  1047.         indent_puts( "yyleng = yy_cp - yy_bp; \\" );
  1048.  
  1049.     /* Now also deal with copying yytext_ptr to yytext if needed. */
  1050.     skelout();
  1051.     if ( yytext_is_array )
  1052.         {
  1053.         indent_puts( "if ( yyleng >= YYLMAX ) \\" );
  1054.         indent_up();
  1055.         indent_puts(
  1056.         "YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\" );
  1057.         indent_down();
  1058.         indent_puts( "yy_flex_strcpy( yytext, yytext_ptr ); \\" );
  1059.         }
  1060.  
  1061.     set_indent( 0 );
  1062.  
  1063.     skelout();
  1064.  
  1065.  
  1066.     printf( "#define YY_END_OF_BUFFER %d\n", num_rules + 1 );
  1067.  
  1068.     if ( fullspd )
  1069.         {
  1070.         /* Need to define the transet type as a size large
  1071.          * enough to hold the biggest offset.
  1072.          */
  1073.         int total_table_size = tblend + numecs + 1;
  1074.         char *trans_offset_type =
  1075.             (total_table_size >= MAX_SHORT || long_align) ?
  1076.                 "long" : "short";
  1077.  
  1078.         set_indent( 0 );
  1079.         indent_puts( "struct yy_trans_info" );
  1080.         indent_up();
  1081.         indent_puts( "{" );     /* } for vi */
  1082.  
  1083.         if ( long_align )
  1084.             indent_puts( "long yy_verify;" );
  1085.         else
  1086.             indent_puts( "short yy_verify;" );
  1087.  
  1088.         /* In cases where its sister yy_verify *is* a "yes, there is
  1089.          * a transition", yy_nxt is the offset (in records) to the
  1090.          * next state.  In most cases where there is no transition,
  1091.          * the value of yy_nxt is irrelevant.  If yy_nxt is the -1th
  1092.          * record of a state, though, then yy_nxt is the action number
  1093.          * for that state.
  1094.          */
  1095.  
  1096.         indent_put2s( "%s yy_nxt;", trans_offset_type );
  1097.         indent_puts( "};" );
  1098.         indent_down();
  1099.         }
  1100.  
  1101.     if ( fullspd )
  1102.         genctbl();
  1103.     else if ( fulltbl )
  1104.         genftbl();
  1105.     else
  1106.         gentabs();
  1107.  
  1108.     /* Definitions for backing up.  We don't need them if REJECT
  1109.      * is being used because then we use an alternative backin-up
  1110.      * technique instead.
  1111.      */
  1112.     if ( num_backing_up > 0 && ! reject )
  1113.         {
  1114.         if ( ! C_plus_plus )
  1115.             {
  1116.             indent_puts(
  1117.             "static yy_state_type yy_last_accepting_state;" );
  1118.             indent_puts(
  1119.                 "static char *yy_last_accepting_cpos;\n" );
  1120.             }
  1121.         }
  1122.  
  1123.     if ( nultrans )
  1124.         {
  1125.         printf( C_state_decl, "yy_NUL_trans", lastdfa + 1 );
  1126.  
  1127.         for ( i = 1; i <= lastdfa; ++i )
  1128.             {
  1129.             if ( fullspd )
  1130.                 printf( "    &yy_transition[%d],\n", base[i] );
  1131.             else
  1132.                 mkdata( nultrans[i] );
  1133.             }
  1134.  
  1135.         dataend();
  1136.         }
  1137.  
  1138.     if ( ddebug )
  1139.         { /* Spit out table mapping rules to line numbers. */
  1140.         indent_puts( "extern int yy_flex_debug;" );
  1141.         indent_puts( "int yy_flex_debug = 1;\n" );
  1142.  
  1143.         printf( long_align ? C_long_decl : C_short_decl,
  1144.             "yy_rule_linenum", num_rules );
  1145.         for ( i = 1; i < num_rules; ++i )
  1146.             mkdata( rule_linenum[i] );
  1147.         dataend();
  1148.         }
  1149.  
  1150.     if ( reject )
  1151.         {
  1152.         /* Declare state buffer variables. */
  1153.         if ( ! C_plus_plus )
  1154.             {
  1155.             puts(
  1156.     "static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;" );
  1157.             puts( "static char *yy_full_match;" );
  1158.             puts( "static int yy_lp;" );
  1159.             }
  1160.  
  1161.         if ( variable_trailing_context_rules )
  1162.             {
  1163.             if ( ! C_plus_plus )
  1164.                 {
  1165.                 puts(
  1166.                 "static int yy_looking_for_trail_begin = 0;" );
  1167.                 puts( "static int yy_full_lp;" );
  1168.                 puts( "static int *yy_full_state;" );
  1169.                 }
  1170.  
  1171.             printf( "#define YY_TRAILING_MASK 0x%x\n",
  1172.                 (unsigned int) YY_TRAILING_MASK );
  1173.             printf( "#define YY_TRAILING_HEAD_MASK 0x%x\n",
  1174.                 (unsigned int) YY_TRAILING_HEAD_MASK );
  1175.             }
  1176.  
  1177.         puts( "#define REJECT \\" );
  1178.         puts( "{ \\" );        /* } for vi */
  1179.         puts(
  1180.     "*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \\" );
  1181.         puts(
  1182.     "yy_cp = yy_full_match; /* restore poss. backed-over text */ \\" );
  1183.  
  1184.         if ( variable_trailing_context_rules )
  1185.             {
  1186.             puts(
  1187.         "yy_lp = yy_full_lp; /* restore orig. accepting pos. */ \\" );
  1188.             puts(
  1189.         "yy_state_ptr = yy_full_state; /* restore orig. state */ \\" );
  1190.             puts(
  1191.     "yy_current_state = *yy_state_ptr; /* restore curr. state */ \\" );
  1192.             }
  1193.  
  1194.         puts( "++yy_lp; \\" );
  1195.         puts( "goto find_rule; \\" );
  1196.         /* { for vi */
  1197.         puts( "}" );
  1198.         }
  1199.  
  1200.     else
  1201.         {
  1202.         puts(
  1203.         "/* The intent behind this definition is that it'll catch" );
  1204.         puts( " * any uses of REJECT which flex missed." );
  1205.         puts( " */" );
  1206.         puts( "#define REJECT reject_used_but_not_detected" );
  1207.         }
  1208.  
  1209.     if ( yymore_used )
  1210.         {
  1211.         if ( ! C_plus_plus )
  1212.             {
  1213.             indent_puts( "static int yy_more_flag = 0;" );
  1214.             indent_puts( "static int yy_more_len = 0;" );
  1215.             }
  1216.  
  1217.         indent_puts( "#define yymore() (yy_more_flag = 1)" );
  1218.         indent_puts( "#define YY_MORE_ADJ yy_more_len" );
  1219.         }
  1220.  
  1221.     else
  1222.         {
  1223.         indent_puts( "#define yymore() yymore_used_but_not_detected" );
  1224.         indent_puts( "#define YY_MORE_ADJ 0" );
  1225.         }
  1226.  
  1227.     if ( ! C_plus_plus )
  1228.         {
  1229.         if ( yytext_is_array )
  1230.             {
  1231.             puts( "#ifndef YYLMAX" );
  1232.             puts( "#define YYLMAX 8192" );
  1233.             puts( "#endif\n" );
  1234.             puts( "char yytext[YYLMAX];" );
  1235.             puts( "char *yytext_ptr;" );
  1236.             }
  1237.  
  1238.         else
  1239.             puts( "char *yytext;" );
  1240.         }
  1241.  
  1242.     fputs( &action_array[defs1_offset], stdout );
  1243.  
  1244.     skelout();
  1245.  
  1246.     if ( ! C_plus_plus )
  1247.         {
  1248.         if ( use_read )
  1249.             {
  1250.             printf(
  1251. "\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\\n" );
  1252.             printf(
  1253.         "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" );
  1254.             }
  1255.  
  1256.         else
  1257.             {
  1258.             printf(
  1259.             "\tif ( yy_current_buffer->yy_is_interactive ) \\\n" );
  1260.             printf( "\t\t{ \\\n" );
  1261.             printf( "\t\tint c = getc( yyin ); \\\n" );
  1262.             printf( "\t\tresult = c == EOF ? 0 : 1; \\\n" );
  1263.             printf( "\t\tbuf[0] = (char) c; \\\n" );
  1264.             printf( "\t\t} \\\n" );
  1265.             printf(
  1266.     "\telse if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \\\n" );
  1267.             printf( "\t\t  && ferror( yyin ) ) \\\n" );
  1268.             printf(
  1269.         "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" );
  1270.             }
  1271.         }
  1272.  
  1273.     skelout();
  1274.  
  1275.     /* Copy prolog to output file. */
  1276.     fputs( &action_array[prolog_offset], stdout );
  1277.  
  1278.     skelout();
  1279.  
  1280.     set_indent( 2 );
  1281.  
  1282.     if ( yymore_used )
  1283.         {
  1284.         indent_puts( "yy_more_len = 0;" );
  1285.         indent_puts( "if ( yy_more_flag )" );
  1286.         indent_up();
  1287.         indent_puts( "{" );
  1288.         indent_puts( "yy_more_len = yyleng;" );
  1289.         indent_puts( "yy_more_flag = 0;" );
  1290.         indent_puts( "}" );
  1291.         indent_down();
  1292.         }
  1293.  
  1294.     skelout();
  1295.  
  1296.     gen_start_state();
  1297.  
  1298.     /* Note, don't use any indentation. */
  1299.     puts( "yy_match:" );
  1300.     gen_next_match();
  1301.  
  1302.     skelout();
  1303.     set_indent( 2 );
  1304.     gen_find_action();
  1305.  
  1306.     skelout();
  1307.     if ( lex_compat )
  1308.         {
  1309.         indent_puts( "if ( yy_act != YY_END_OF_BUFFER )" );
  1310.         indent_up();
  1311.         indent_puts( "{" );
  1312.         indent_puts( "int yyl;" );
  1313.         indent_puts( "for ( yyl = 0; yyl < yyleng; ++yyl )" );
  1314.         indent_up();
  1315.         indent_puts( "if ( yytext[yyl] == '\\n' )" );
  1316.         indent_up();
  1317.         indent_puts( "++yylineno;" );
  1318.         indent_down();
  1319.         indent_down();
  1320.         indent_puts( "}" );
  1321.         indent_down();
  1322.         }
  1323.  
  1324.     skelout();
  1325.     if ( ddebug )
  1326.         {
  1327.         indent_puts( "if ( yy_flex_debug )" );
  1328.         indent_up();
  1329.  
  1330.         indent_puts( "{" );
  1331.         indent_puts( "if ( yy_act == 0 )" );
  1332.         indent_up();
  1333.         indent_puts(
  1334.             "fprintf( stderr, \"--scanner backing up\\n\" );" );
  1335.         indent_down();
  1336.  
  1337.         do_indent();
  1338.         printf( "else if ( yy_act < %d )\n", num_rules );
  1339.         indent_up();
  1340.         indent_puts(
  1341.     "fprintf( stderr, \"--accepting rule at line %d (\\\"%s\\\")\\n\"," );
  1342.         indent_puts( "         yy_rule_linenum[yy_act], yytext );" );
  1343.         indent_down();
  1344.  
  1345.         do_indent();
  1346.         printf( "else if ( yy_act == %d )\n", num_rules );
  1347.         indent_up();
  1348.         indent_puts(
  1349.     "fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\"," );
  1350.         indent_puts( "         yytext );" );
  1351.         indent_down();
  1352.  
  1353.         do_indent();
  1354.         printf( "else if ( yy_act == %d )\n", num_rules + 1 );
  1355.         indent_up();
  1356.         indent_puts(
  1357.     "fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );" );
  1358.         indent_down();
  1359.  
  1360.         do_indent();
  1361.         printf( "else\n" );
  1362.         indent_up();
  1363.         indent_puts(
  1364.     "fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );" );
  1365.         indent_down();
  1366.  
  1367.         indent_puts( "}" );
  1368.         indent_down();
  1369.         }
  1370.  
  1371.     /* Copy actions to output file. */
  1372.     skelout();
  1373.     indent_up();
  1374.     gen_bu_action();
  1375.     fputs( &action_array[action_offset], stdout );
  1376.  
  1377.     /* generate cases for any missing EOF rules */
  1378.     for ( i = 1; i <= lastsc; ++i )
  1379.         if ( ! sceof[i] )
  1380.             {
  1381.             do_indent();
  1382.             printf( "case YY_STATE_EOF(%s):\n", scname[i] );
  1383.             did_eof_rule = true;
  1384.             }
  1385.  
  1386.     if ( did_eof_rule )
  1387.         {
  1388.         indent_up();
  1389.         indent_puts( "yyterminate();" );
  1390.         indent_down();
  1391.         }
  1392.  
  1393.  
  1394.     /* Generate code for handling NUL's, if needed. */
  1395.  
  1396.     /* First, deal with backing up and setting up yy_cp if the scanner
  1397.      * finds that it should JAM on the NUL>
  1398.      */
  1399.     skelout();
  1400.     set_indent( 7 );
  1401.  
  1402.     if ( fullspd || fulltbl )
  1403.         indent_puts( "yy_cp = yy_c_buf_p;" );
  1404.  
  1405.     else
  1406.         { /* compressed table */
  1407.         if ( ! reject && ! interactive )
  1408.             {
  1409.             /* Do the guaranteed-needed backing up to figure
  1410.              * out the match.
  1411.              */
  1412.             indent_puts( "yy_cp = yy_last_accepting_cpos;" );
  1413.             indent_puts(
  1414.                 "yy_current_state = yy_last_accepting_state;" );
  1415.             }
  1416.         }
  1417.  
  1418.  
  1419.     /* Generate code for yy_get_previous_state(). */
  1420.     set_indent( 1 );
  1421.     skelout();
  1422.  
  1423.     if ( bol_needed )
  1424.         indent_puts( "register char *yy_bp = yytext_ptr;\n" );
  1425.  
  1426.     gen_start_state();
  1427.  
  1428.     set_indent( 2 );
  1429.     skelout();
  1430.     gen_next_state( true );
  1431.  
  1432.     set_indent( 1 );
  1433.     skelout();
  1434.     gen_NUL_trans();
  1435.  
  1436.     skelout();
  1437.     if ( lex_compat )
  1438.         { /* update yylineno inside of unput() */
  1439.         indent_puts( "if ( c == '\\n' )" );
  1440.         indent_up();
  1441.         indent_puts( "--yylineno;" );
  1442.         indent_down();
  1443.         }
  1444.  
  1445.     skelout();
  1446.  
  1447.     /* Copy remainder of input to output. */
  1448.  
  1449.     line_directive_out( stdout );
  1450.  
  1451.     if ( sectnum == 3 )
  1452.         (void) flexscan(); /* copy remainder of input to output */
  1453.     }
  1454.